<template>
    <div class="container">

        <el-row>
            <el-col :span="24">
                
                <div class="grid-content bg-purple-dark">
                     <el-input type="password" placeholder="密码" v-model="password">
                        <template slot="prepend">密码</template>
                    </el-input>

                    <el-button type="primary" @click="wl_login()" style="width:100%;margin-top:50px;">登录</el-button>

                </div>
            </el-col>
        </el-row>

    </div>
</template>

<script>
import conf from '../layout/conf.vue'//引用模块进来
    export default {
        mounted() {
        this.ymh();
        },
        data(){
            return {
                list: {},
                email:"",
                password:"",
                form:[],
                url:conf.url+"/user/login/index/",

            }


        },

        methods:{
            wl_login(){
                var self=this;
                var params = new URLSearchParams();
                params.append('user_email',this.$config('adminEmail'));
                params.append('user_pwd', this.password);

                this.axios.post(this.url,params).then(response=>{
                    console.log(response);
                     var info=response.data;
 
                     if(info.status==1){
                            var user=info['data'][0];
                         
                           this.$layer.msg("登录成功!");

                            this.SetCookie("wlphp.cn", "", -1);
                            this.SetCookie("name", "", -1);
                            this.SetCookie("tou", "", -1);
            
                            this.SetCookie("wlphp.cn",user.access_token,'1');
                            this.SetCookie("name",user.username,'1');
                            this.SetCookie("tou",user.tou,'1');
                            setTimeout(function () {
                                // location.href="/";
                                // this.$router.push({path:'/login'});
                                self.$router.push('/')
                            },1000)
                     }else{

                         this.$layer.msg(info.message);
                     }

                     

                     return;

                });
            },

        }


    }


</script>
